package com.gitee.cirnochat.websocket.model.vo.resp;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.gitee.cirnochat.chat.model.enums.MessageOperation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
@Schema(description = "在线系统消息视图信息")
public class WebSocketMessageResponse {
    /**
     * 消息状态码
     */
    @Schema(description = "消息状态码")
    private int code;
    /**
     * 提示信息
     */
    @Schema(description = "提示信息")
    private String message;
    /**
     * 消息操作
     */
    @Schema(description = "消息操作类型")
    private MessageOperation operation;
    /**
     * 关联的消息ID
     */
    @Schema(description = "关联的消息ID")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long messageId;

    public static final WebSocketMessageResponseBuilder Builder = new WebSocketMessageResponseBuilder();

    public static class WebSocketMessageResponseBuilder {
        public WebSocketMessageResponseBuilder code(int code) {
            OPTIONS.code = code;
            return this;
        }



        public WebSocketMessageResponseBuilder message(String message) {
            OPTIONS.message = message;
            return this;
        }

        public WebSocketMessageResponseBuilder operation(MessageOperation operation) {
            OPTIONS.operation = operation;
            return this;
        }

        public WebSocketMessageResponseBuilder messageId(Long messageId) {
            OPTIONS.messageId = messageId;
            return this;
        }

        public WebSocketMessageResponse build() {
            WebSocketMessageResponse vo = new WebSocketMessageResponse();
            vo.code = OPTIONS.code;
            vo.message = OPTIONS.message;
            vo.operation = OPTIONS.operation;
            vo.messageId = OPTIONS.messageId;
            OPTIONS.reset();
            return vo;
        }
    }


    private final static WebSocketMessageResponseOptions OPTIONS = new WebSocketMessageResponseOptions();

    private static class WebSocketMessageResponseOptions {
        private int code;
        private String message;
        private MessageOperation operation;
        private Long messageId;

        public WebSocketMessageResponseOptions code(int code) {
            this.code = code;
            return this;
        }
        public WebSocketMessageResponseOptions message(String message) {
            this.message = message;
            return this;
        }
        public WebSocketMessageResponseOptions operation(MessageOperation operation) {
            this.operation = operation;
            return this;
        }

        public WebSocketMessageResponseOptions messageId(Long messageId) {
            this.messageId = messageId;
            return this;
        }

        public void reset() {
            this.code = 0;
            this.message = null;
            this.operation = null;
            this.messageId = null;
        }
    }
}
